#include <stdio.h>

int main(int argc, char *argv[])
{
	int p, q, n, a[20000][2];
	int i, flg;
	
	scanf("%d %d %d", &p, &q, &n);

	flg = 0;
	for (i=0; i<n; i++) {
		scanf("%d %d", &a[i][0], &a[i][1]);
		if (a[i][1] >= p && a[i][1] <= q) {
			flg = 1;
			printf("%d\n", a[i][0]);
		}
	}

	if (flg == 0) printf("NONE!\n");

	return 0;
}
